package com.whmskj.xjlhsc.mobie.personnelFile.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;
import java.util.List;

@Data
public class LeaveApplicationDetailDTO {
    @Schema(description = "请假申请ID")
    private Integer id;
    @Schema(description = "员工ID")
    private Integer employeeId;
    @Schema(description = "员工姓名")
    private String employeeName;
    @Schema(description = "员工工号")
    private String employeeCode;
    @Schema(description = "员工显示名称")
    private String employeeDisplay;
    @Schema(description = "员工部门")
    private String employeeDept;
    @Schema(description = "员工职位")
    private String positions;
    @Schema(description = "员工工种类型")
    private String typeOfWork;
    @Schema(description = "请假类型")
    private String leaveType;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "开始时间")
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "结束时间")
    private LocalDateTime endTime;
    @Schema(description = "请假天数")
    private Integer leaveDays;
    @Schema(description = "图片")
    private List<String> proofImages;
    @Schema(description = "事由")
    private String reason;
    @Schema(description = "状态")
    private String status;
    @Schema(description = "当前审批人ID")
    private Integer currentApproverId;
    @Schema(description = "当前审批人名称")
    private String currentApproverName;
    @Schema(description = "撤销原因")
    private String cancelReason;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "申请时间")
    private LocalDateTime applicationTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;
    
    @Schema(description = "审批记录列表")
    private List<ApprovalRecordDTO> approvalRecords;

    // —— 前端流程编排渲染所需增强字段 ——
    @Schema(description = "审批节点顺序")
    private List<String> approvalFlow;

    @Schema(description = "当前应审批节点")
    private String currentNode;

    @Schema(description = "流程节点明细（含每节点应审批人/状态/时间/意见）")
    private List<FlowNodeDTO> nodes;

    @Schema(description = "已完成节点数量")
    private Integer progress;

    @Schema(description = "下一审批人ID")
    private Integer nextApproverId;

    @Schema(description = "下一审批人姓名")
    private String nextApproverName;
    
    @Data
    public static class ApprovalRecordDTO {
        @Schema(description = "审批节点名称")
        private String approvalNode;
        
        @Schema(description = "审批人姓名")
        private String approverName;
        
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        @Schema(description = "审批时间")
        private LocalDateTime approvalTime;
        
        @Schema(description = "审批意见")
        private String approvalOpinion;
        
        @Schema(description = "审批结果")
        private String approvalStatus;
    }

    @Data
    public static class FlowNodeDTO {
        @Schema(description = "节点名称")
        private String node;
        @Schema(description = "应审批人ID")
        private Integer approverId;
        @Schema(description = "应审批人姓名")
        private String approverName;
        @Schema(description = "节点状态：pending/approved/rejected")
        private String status;
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        @Schema(description = "审批时间")
        private LocalDateTime approvalTime;
        @Schema(description = "审批意见")
        private String opinion;
    }
}


